package com.content
{
	import com.content.controller.AppCommand;
	import com.content.controller.ContentCommand;
	import com.content.model.LoadedAssets.ConfigProxy;
	import com.content.model.LoadedAssets.FontProxy;
	import com.content.model.LoadedAssets.SkinProxy;
	import com.content.view.Frame.CBar.CBar;
	
	import org.puremvc.as3.interfaces.IFacade;
	import org.puremvc.as3.patterns.facade.Facade;
	import org.puremvc.as3.patterns.observer.Notification;
	import org.puremvc.as3.utilities.startupmanager.controller.StartupResourceFailedCommand;
	import org.puremvc.as3.utilities.startupmanager.controller.StartupResourceLoadedCommand;

	/**
	 * AppFacade 主要用来注册 Controller 中的 Command
	 * SwiftMVC 中的核心是 Command，所有的 Mediator 与 Proxy 均是在 Command 中通过 facade 注册
	 * */
	public class AppFacade extends Facade implements IFacade
	{
		public static const NAME:String						= 'ApplicationFacade';
		
		public static const STARTUP:String					= NAME + "-" + 'StartUp';
		public static const APP_INIT:String 				= NAME + "-" + "AppInit";
		public static const APP_QUIT:String 				= NAME + "-" + "AppQuit";	
		
		public static const MAINPANEL_OPEN:String 				= NAME + "-" + "MainPanelOpen";
		
		override protected function initializeController():void
		{
			super.initializeController();	
			
			registerCommand( STARTUP, AppCommand );
			registerCommand( APP_INIT, AppCommand );
			registerCommand( APP_QUIT, AppCommand );
		}
		
		override public function sendNotification(notificationName:String, body:Object=null, type:String=null):void
		{
			//trace( 'Sent ' + notificationName );	
			notifyObservers( new Notification( notificationName, body, type ) );
		}
		
		public function startup(app:Object):void{
			sendNotification( STARTUP, 	app );	// SwiftMVC starts from here, "stage" obj is passed over to AppMediator
		}
		
		public static function getInstance():AppFacade	{return (instance ? instance : new AppFacade()) as AppFacade;}
	}
}